//格网图层
const LineLayer = new ol.layer.Vector({
    projection: "EPSG:4326",
})
//图幅显示图层
const RectangularLayer = new ol.layer.Vector({
    projection: "EPSG:4326",
})
//搜索图层
const SearchSheetLayer = new ol.layer.Vector({
    projection: "EPSG:4326",
})
//选择图层
const SelectSheetLayer = new ol.layer.Vector({
    projection: "EPSG:4326",
})

function display_save(scale, select_type) {
    var url;
    var color;
    var lnglat;
    if (select_type == 1) {
        switch (scale) {
            case 100:
                url = "http://localhost:8888/paper/map/inventory/table/select?fieldName=scale&value=100";
                color = "rgb(255,255,0,0.5)";
                lnglat = lnglat_100;
                break;
            case 50:
                url = "http://localhost:8888/paper/map/inventory/table/select?fieldName=scale&value=50";
                color = "rgb(0,206,209,0.5)";
                lnglat = lnglat_50;
                break;
            case 25:
                url = "http://localhost:8888/paper/map/inventory/table/select?fieldName=scale&value=25";
                color = "rgb(152,251,152,0.5)";
                lnglat = lnglat_25;
                break;
            case 10:
                url = "http://localhost:8888/paper/map/inventory/table/select?fieldName=scale&value=10";
                color = "rgb(46,139,87,0.5)";
                lnglat = lnglat_10;
                break;
            case 5:
                url = "http://localhost:8888/paper/map/inventory/table/select?fieldName=scale&value=5";
                color = "rgb(255,165,0,0.5)";
                lnglat = lnglat_5;
                break;
            case 1:
                url = "http://localhost:8888/paper/map/inventory/table/select?fieldName=scale&value=1";
                color = "rgb(189,183,107,0.5)";
                lnglat = lnglat_1;
                break;
        }
    }

    $.ajax({
        type: "POST",
        url: url,
        dataType: "JSON",
        // data: data1,
        success: function (result) {
            console.log(result);
            var data = result.data;
            for (var i = 0; i < data.length; i++) {
                var sheet = data[i].sheet;
                addRectangular(sheet, lnglat, color, scale,RectangularLayer)
            }
        },
        error: function (result) {
            console.log(result);
        }
    });
    RectangularLayer.setSource(rectangleSource);
    map.addLayer(RectangularLayer);
}